<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - lbp.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2014  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_LBP_Hh_
<font color='#0000FF'>#define</font> DLIB_LBP_Hh_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='lbp_abstract.h.html'>lbp_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../image_processing/generic_image.h.html'>../image_processing/generic_image.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='assign_image.h.html'>assign_image.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../pixel.h.html'>../pixel.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='make_uniform_lbp_image'></a>make_uniform_lbp_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img_,
        image_type2<font color='#5555FF'>&amp;</font> lbp_
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> uniform_lbps[] <font color='#5555FF'>=</font> <b>{</b>
            <font color='#979000'>0</font>, <font color='#979000'>1</font>, <font color='#979000'>2</font>, <font color='#979000'>3</font>, <font color='#979000'>4</font>, <font color='#979000'>58</font>, <font color='#979000'>5</font>, <font color='#979000'>6</font>, <font color='#979000'>7</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>8</font>, <font color='#979000'>58</font>, <font color='#979000'>9</font>, <font color='#979000'>10</font>, <font color='#979000'>11</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>12</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>13</font>, <font color='#979000'>58</font>, <font color='#979000'>14</font>, <font color='#979000'>15</font>, <font color='#979000'>16</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>17</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>18</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>19</font>, <font color='#979000'>58</font>,
            <font color='#979000'>20</font>, <font color='#979000'>21</font>, <font color='#979000'>22</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>23</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>24</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>25</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>26</font>, <font color='#979000'>58</font>, <font color='#979000'>27</font>, <font color='#979000'>28</font>, <font color='#979000'>29</font>, <font color='#979000'>30</font>, <font color='#979000'>58</font>, <font color='#979000'>31</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>32</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>33</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>34</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>35</font>, <font color='#979000'>36</font>, <font color='#979000'>37</font>, <font color='#979000'>58</font>, <font color='#979000'>38</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>39</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>40</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>,
            <font color='#979000'>58</font>, <font color='#979000'>41</font>, <font color='#979000'>42</font>, <font color='#979000'>43</font>, <font color='#979000'>58</font>, <font color='#979000'>44</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>45</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>46</font>, <font color='#979000'>47</font>, <font color='#979000'>48</font>,
            <font color='#979000'>58</font>, <font color='#979000'>49</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>58</font>, <font color='#979000'>50</font>, <font color='#979000'>51</font>, <font color='#979000'>52</font>, <font color='#979000'>58</font>, <font color='#979000'>53</font>, <font color='#979000'>54</font>, <font color='#979000'>55</font>, <font color='#979000'>56</font>, <font color='#979000'>57</font>
        <b>}</b>;

        <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>uniform_lbps<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>256</font><font face='Lucida Console'>)</font>;

        const_image_view<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>img</font><font face='Lucida Console'>(</font>img_<font face='Lucida Console'>)</font>;
        image_view<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>lbp</font><font face='Lucida Console'>(</font>lbp_<font face='Lucida Console'>)</font>;

        lbp.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        <font color='#009900'>// set all the border pixels to the "non-uniform LBP value".
</font>        <font color='#BB00BB'>assign_border_pixels</font><font face='Lucida Console'>(</font>lbp, <font color='#979000'>1</font>, <font color='#979000'>1</font>, <font color='#979000'>58</font><font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> pixel_traits<font color='#5555FF'>&lt;</font>pixel_type<font color='#5555FF'>&gt;</font>::basic_pixel_type basic_pixel_type;

        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>1</font>; r<font color='#5555FF'>+</font><font color='#979000'>1</font> <font color='#5555FF'>&lt;</font> img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>1</font>; c<font color='#5555FF'>+</font><font color='#979000'>1</font> <font color='#5555FF'>&lt;</font> img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> basic_pixel_type pix <font color='#5555FF'>=</font> <font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r][c]<font face='Lucida Console'>)</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b1 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b2 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b3 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b4 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b5 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b6 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b7 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> b8 <font color='#5555FF'>=</font> <font color='#979000'>0</font>;

                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> x <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b1 <font color='#5555FF'>=</font> <font color='#979000'>0x80</font>; 
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c  ]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b2 <font color='#5555FF'>=</font> <font color='#979000'>0x40</font>;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b3 <font color='#5555FF'>=</font> <font color='#979000'>0x20</font>;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b1;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r  ][c<font color='#5555FF'>-</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b4 <font color='#5555FF'>=</font> <font color='#979000'>0x10</font>;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b2;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r  ][c<font color='#5555FF'>+</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b5 <font color='#5555FF'>=</font> <font color='#979000'>0x08</font>;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b3;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b6 <font color='#5555FF'>=</font> <font color='#979000'>0x04</font>;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b4;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c  ]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b7 <font color='#5555FF'>=</font> <font color='#979000'>0x02</font>;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b5;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_pixel_intensity</font><font face='Lucida Console'>(</font>img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> pix<font face='Lucida Console'>)</font> b8 <font color='#5555FF'>=</font> <font color='#979000'>0x01</font>;

                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b6;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b7;
                x <font color='#5555FF'>|</font><font color='#5555FF'>=</font> b8;

                lbp[r][c] <font color='#5555FF'>=</font> uniform_lbps[x];
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_histogram_descriptors'></a>extract_histogram_descriptors</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img_,
        <font color='#0000FF'>const</font> point<font color='#5555FF'>&amp;</font> loc,
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> histograms,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cell_size <font color='#5555FF'>=</font> <font color='#979000'>10</font>,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> block_size <font color='#5555FF'>=</font> <font color='#979000'>4</font>,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> max_val <font color='#5555FF'>=</font> <font color='#979000'>58</font>
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>cell_size <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> block_size <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> max_val <font color='#5555FF'>&lt;</font> <font color='#979000'>256</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> 
                    <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>mat</font><font face='Lucida Console'>(</font>img_<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> max_val,
            "<font color='#CC0000'>\t void extract_histogram_descriptors()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t cell_size:      </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cell_size
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t block_size:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> block_size
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t max_val:        </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> max_val
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t max(mat(img_)): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>mat</font><font face='Lucida Console'>(</font>img_<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;
        <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font>pixel_type, <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font>::value<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        const_image_view<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>img</font><font face='Lucida Console'>(</font>img_<font face='Lucida Console'>)</font>;

        <font color='#0000FF'>const</font> rectangle area <font color='#5555FF'>=</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> rectangle window <font color='#5555FF'>=</font> <font color='#BB00BB'>centered_rect</font><font face='Lucida Console'>(</font>loc, block_size<font color='#5555FF'>*</font>cell_size, block_size<font color='#5555FF'>*</font>cell_size<font face='Lucida Console'>)</font>;
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cell_top <font color='#5555FF'>=</font> window.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> br <font color='#5555FF'>=</font> <font color='#979000'>0</font>; br <font color='#5555FF'>&lt;</font> block_size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>br<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cell_left <font color='#5555FF'>=</font> window.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> bc <font color='#5555FF'>=</font> <font color='#979000'>0</font>; bc <font color='#5555FF'>&lt;</font> block_size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>bc<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#009900'>// figure out the cell boundaries
</font>                rectangle <font color='#BB00BB'>cell</font><font face='Lucida Console'>(</font>cell_left, cell_top, cell_left<font color='#5555FF'>+</font>cell_size<font color='#5555FF'>-</font><font color='#979000'>1</font>, cell_top<font color='#5555FF'>+</font>cell_size<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
                cell <font color='#5555FF'>=</font> cell.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font>area<font face='Lucida Console'>)</font>;

                <font color='#009900'>// make the actual histogram for this cell
</font>                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> hist[<font color='#979000'>256</font>] <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0</font><b>}</b>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> cell.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; r <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> cell.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> cell.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; c <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> cell.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                    <b>{</b>
                        hist[img[r][c]]<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
                    <b>}</b>
                <b>}</b>

                <font color='#009900'>// copy histogram into the output.
</font>                histograms.<font color='#BB00BB'>insert</font><font face='Lucida Console'>(</font>histograms.<font color='#BB00BB'>end</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, hist, hist <font color='#5555FF'>+</font> max_val<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;

                cell_left <font color='#5555FF'>+</font><font color='#5555FF'>=</font> cell_size;
            <b>}</b>
            cell_top <font color='#5555FF'>+</font><font color='#5555FF'>=</font> cell_size;
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_uniform_lbp_descriptors'></a>extract_uniform_lbp_descriptors</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> feats,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cell_size <font color='#5555FF'>=</font> <font color='#979000'>10</font>
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>cell_size <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font>,
            "<font color='#CC0000'>\t void extract_uniform_lbp_descriptors()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t cell_size:      </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cell_size
            <font face='Lucida Console'>)</font>;

        feats.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        array2d<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font> lbp;
        <font color='#BB00BB'>make_uniform_lbp_image</font><font face='Lucida Console'>(</font>img, lbp<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> lbp.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; r<font color='#5555FF'>+</font><font color='#5555FF'>=</font>cell_size<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> lbp.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; c<font color='#5555FF'>+</font><font color='#5555FF'>=</font>cell_size<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> rectangle cell <font color='#5555FF'>=</font> <font color='#BB00BB'>rectangle</font><font face='Lucida Console'>(</font>c,r,c<font color='#5555FF'>+</font>cell_size<font color='#5555FF'>-</font><font color='#979000'>1</font>,r<font color='#5555FF'>+</font>cell_size<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>lbp<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#009900'>// make the actual histogram for this cell
</font>                <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> hist[<font color='#979000'>59</font>] <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0</font><b>}</b>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> cell.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; r <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> cell.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> cell.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; c <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> cell.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                    <b>{</b>
                        hist[lbp[r][c]]<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
                    <b>}</b>
                <b>}</b>

                <font color='#009900'>// copy histogram into the output.
</font>                feats.<font color='#BB00BB'>insert</font><font face='Lucida Console'>(</font>feats.<font color='#BB00BB'>end</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, hist, hist <font color='#5555FF'>+</font> <font color='#979000'>59</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> feats.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            feats[i] <font color='#5555FF'>=</font> std::<font color='#BB00BB'>sqrt</font><font face='Lucida Console'>(</font>feats[i]<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_highdim_face_lbp_descriptors'></a>extract_highdim_face_lbp_descriptors</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> det,
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> feats
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>68</font>,
            "<font color='#CC0000'>\t void extract_highdim_face_lbp_descriptors()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t det.num_parts(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> det.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num_scales <font color='#5555FF'>=</font> <font color='#979000'>5</font>; 
        feats.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> l, r;
        <font color='#0000FF'><u>double</u></font> cnt <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
        <font color='#009900'>// Find the center of the left eye by averaging the points around 
</font>        <font color='#009900'>// the eye.
</font>        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>36</font>; i <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>41</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font> 
        <b>{</b>
            l <font color='#5555FF'>+</font><font color='#5555FF'>=</font> det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <font color='#5555FF'>+</font><font color='#5555FF'>+</font>cnt;
        <b>}</b>
        l <font color='#5555FF'>/</font><font color='#5555FF'>=</font> cnt;

        <font color='#009900'>// Find the center of the right eye by averaging the points around 
</font>        <font color='#009900'>// the eye.
</font>        cnt <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>42</font>; i <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>47</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font> 
        <b>{</b>
            r <font color='#5555FF'>+</font><font color='#5555FF'>=</font> det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <font color='#5555FF'>+</font><font color='#5555FF'>+</font>cnt;
        <b>}</b>
        r <font color='#5555FF'>/</font><font color='#5555FF'>=</font> cnt;

        <font color='#009900'>// We only do feature extraction from these face parts.  These are things like the
</font>        <font color='#009900'>// corners of the eyes and mouth and stuff like that.
</font>        std::vector<font color='#5555FF'>&lt;</font>point<font color='#5555FF'>&gt;</font> parts;
        parts.<font color='#BB00BB'>reserve</font><font face='Lucida Console'>(</font><font color='#979000'>30</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>l<font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r<font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>17</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>21</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>22</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>26</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>36</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>39</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>42</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>45</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>27</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>28</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>29</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>30</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>31</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>35</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>33</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>48</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>54</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>51</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font><font color='#979000'>57</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        array2d<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font> lbp;
        <font color='#BB00BB'>make_uniform_lbp_image</font><font face='Lucida Console'>(</font>img, lbp<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> parts.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <font color='#BB00BB'>extract_histogram_descriptors</font><font face='Lucida Console'>(</font>lbp, parts[i], feats<font face='Lucida Console'>)</font>;

        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>num_scales <font color='#5555FF'>&gt;</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
        <b>{</b>
            pyramid_down<font color='#5555FF'>&lt;</font><font color='#979000'>4</font><font color='#5555FF'>&gt;</font> pyr;
            image_type img_temp;
            <font color='#BB00BB'>pyr</font><font face='Lucida Console'>(</font>img, img_temp<font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num_pyr_calls <font color='#5555FF'>=</font> <font color='#979000'>1</font>;

            <font color='#009900'>// now pull the features out at coarser scales
</font>            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> iter <font color='#5555FF'>=</font> <font color='#979000'>1</font>; iter <font color='#5555FF'>&lt;</font> num_scales; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>iter<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#009900'>// now do the feature extraction
</font>                <font color='#BB00BB'>make_uniform_lbp_image</font><font face='Lucida Console'>(</font>img_temp, lbp<font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> parts.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>extract_histogram_descriptors</font><font face='Lucida Console'>(</font>lbp, pyr.<font color='#BB00BB'>point_down</font><font face='Lucida Console'>(</font>parts[i],num_pyr_calls<font face='Lucida Console'>)</font>, feats<font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>iter<font color='#5555FF'>+</font><font color='#979000'>1</font> <font color='#5555FF'>&lt;</font> num_scales<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>pyr</font><font face='Lucida Console'>(</font>img_temp<font face='Lucida Console'>)</font>;
                    <font color='#5555FF'>+</font><font color='#5555FF'>+</font>num_pyr_calls;
                <b>}</b>
            <b>}</b>
        <b>}</b>

        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> feats.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            feats[i] <font color='#5555FF'>=</font> std::<font color='#BB00BB'>sqrt</font><font face='Lucida Console'>(</font>feats[i]<font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>feats.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>99120</font>, feats.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_LBP_Hh_
</font>

</pre></body></html>